<template>
  <div class="Remark">
    <el-dialog 
      title="修改备注" 
      :visible.sync="dialogFormVisible" 
      :center="isCenter" 
      width="500px">
      <el-form :model="dataForm" ref="dataForm" :rules="roleRules">
        <el-form-item label="备注：" prop="results" label-width="100px">
          <el-input type="textarea" v-model="dataForm.remark" autocomplete="off" :rows="5" :cols="30"></el-input>
        </el-form-item>
        <el-form-item align="center">
          <el-button @click.native="clickCancel">取 消</el-button>
          <el-button type="primary" @click.native="clickCommit">确 定</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>
<script>
  import * as message from "@/constants/message";

  export default {
    name: 'Remarks',
    props: {
      remark: {
        type: String,
        default: null
      }
    },
    created() {
      //this.dataForm.relationId = this.props.relationId
    },
    watch:{
      remark(value) {
        this.dataForm.remark = value
      }
    },
    data() {
      return {
        dataForm:{
          remark:""
        },
        dialogFormVisible: false,
        isCenter: true,
        roleRules: {
          remark: [
            { required: true, message: "请输入备注内容", trigger: "blur" },
            { max: 200, message: '备注内容长度不超过200个字', trigger: 'blur' }
          ],
        }
      }
    },
    methods: {
      clickCancel(){
        this.dialogFormVisible = false;
        this.dataForm.remark="";
      },
      clickCommit() {
        this.$refs.dataForm.validate(valid => {
          if (valid) {
            this.$emit('getRemark', this.dataForm.remark)
            this.dialogFormVisible = false
          }
        })
      },
      handleCreate() {
        this.dialogFormVisible = true
      }

    }
  }
</script>
<style lang="scss">
  .variant-input {
    margin-top: 2px
  }

  .Remark .country_ul {
    position: relative;
  }

  .country_ul .country_tabs {
    float: left;
    margin-bottom: 0;
    padding-left: 0;
    list-style: none;
    margin-bottom: -4px;
  }

  .country_ul .country_tabs li {
    float: left;
    cursor: pointer;
    background-color: #eee;
    width: 60px;
    height: 35px;
    margin-right: 5px;
    border: 1px solid #ddd;
    border-radius: 6px;
  }

  .country_ul .country_tabs .active {
    background-color: #fff;
  }

  .country_ul .country_tabs li a {
    span {
      line-height: 30px;
      margin-left: 15px;
    }
  }

  .variant_btn {
    display: flex;
    justify-content: center;
    margin-top: 10px;
  }
</style>
